import org.junit.*;
import com.thoughtworks.selenium.*;


public class TestGmailAccount {
	
	Selenium BO; 
	
	
	@Before
	public void setUp() throws Exception {
		BO = new DefaultSelenium("localhost",4444,"*firefox","http://mail.google.com");
		BO.start();
		
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testCorrectLogin()
	{
		String userNameTextBox = "//TABLE[@id='gaia_table']/TBODY/TR[@id='email-row']/TD[2]/INPUT[@id='Email']";
		String passwordTextBox ="//TABLE[@id='gaia_table']/TBODY/TR[@id='password-row']/TD[2]/INPUT[@id='Passwd']";
		String buttonLink = "//TABLE[@id='gaia_table']/TBODY/TR[8]/TD[2]/INPUT[@id='signIn']";
		String mailCount;
		getBrowserReady();
		
		BO.type(userNameTextBox, "blusciusa");
		BO.type(passwordTextBox, "tulu0016");
		clickAndLoadNextPage(buttonLink);
		//click on compose button
		BO.clickAt("//div[@id=':co']/div[1]/div", "0,0");
		//select inbox
		mailCount = (BO.getText("//div[@id=':ck']/div/span"));
		System.out.println(mailCount.substring(7, 8));
		
		
		//*********Type email address in To text area 
		//BO.type("//table[@id=':77']/tbody/tr/td[2]/textarea","nthigale@hotmail.com");
		//********Type subject
		//BO.type("//table[@id=':77']/tbody/tr[5]/td[2]/input", "Hello!");
		//********Click on Send button (not working)
		//BO.clickAt("//div[@id=':6i']", "0,0");
		
	}
	
	public void getBrowserReady()
	{
		BO.open("/");
		BO.windowMaximize();
	}
	
	public void clickAndLoadNextPage(String page)
	{	//BO.clickAt(page);
		BO.clickAt(page,"0");
		
		BO.waitForPageToLoad("60000");
	}
}
